import { Client } from "../../dist/esm/index.js";
const send2Son = document.querySelector("#send2Son");
const invokeSon = document.querySelector("#invokeSon");
export const init = async () => {
  const client = new Client({
    target: window.parent,
    handlers: {
      son2info: console.info,
    },
  });
  client.mount();
  client.on("msg", console.log.bind(null, "son2收到消息"));
  send2Son.addEventListener("click", () => {
    client.send({ type: "msg", data: { name: "son2" } });
  });
  invokeSon.addEventListener("click", () => {
    client.invokeHandler({ type: "info", data: ["son2"] });
  });
};
